<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <el-input
          v-model="query.name"
          clearable
          size="small"
          placeholder="输入文章名称搜索"
          style="width: 200px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <el-input
          v-model="query.userName"
          clearable
          size="small"
          placeholder="输入用户名搜索"
          style="width: 200px;"
          class="filter-item"
          @keyup.enter.native="crud.toQuery"
        />
        <el-select
          v-model="query.inOutType"
          clearable
          size="small"
          placeholder="收支类型"
          class="filter-item"
          style="width: 100px"
          @change="crud.toQuery"
        >
          <el-option v-for="item in inOutTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
        </el-select>
        <el-select
          v-model="query.businessType"
          clearable
          size="small"
          placeholder="交易类型"
          class="filter-item"
          style="width: 100px"
          @change="crud.toQuery"
        >
          <el-option v-for="item in businessTypeOptions" :key="item.key" :label="item.display_name" :value="item.key" />
        </el-select>
        <date-range-picker v-model="query.createTime" class="date-item" unlink-panels />
        <rrOperation />
      </div>
      <crudOperation />
    </div>
    <!--表格渲染-->
    <el-table
      ref="table"
      v-loading="crud.loading"
      lazy
      :data="crud.data"
      row-key="id"
      @select="crud.selectChange"
      @select-all="crud.selectAllChange"
      @selection-change="crud.selectionChangeHandler"
    >
      <el-table-column type="selection" width="55" />
      <el-table-column label="用户" prop="userName" />
      <el-table-column label="类型" prop="inOutType">
        <template slot-scope="scope">
          <div>
            <span v-if="scope.row.inOutType === 0">收入</span>
            <span v-if="scope.row.inOutType === 1">支出</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="价格" prop="price" />
      <el-table-column label="交易类型" prop="businessType">
        <template slot-scope="scope">
          <div>
            <span v-if="scope.row.businessType === 0">VIP充值</span>
            <span v-if="scope.row.businessType === 1">购买文章</span>
            <span v-if="scope.row.businessType === 2">购买答案</span>
          </div>
        </template>
      </el-table-column>

      <el-table-column label="名称" prop="articleName">
        <template slot-scope="scope">
          <div>
            <span v-if="scope.row.businessType === 1">{{ scope.row.articleName }}</span>
            <span v-if="scope.row.businessType === 2">{{ scope.row.queryName }}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="购买者" prop="buyUname" />
      <el-table-column label="购买时间" prop="createTime" />
    </el-table>
    <!--分页组件-->
    <pagination />
  </div>
</template>

<script>
import crudBislog from '@/api/system/bislog'
import CRUD, { crud, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import DateRangePicker from '@/components/DateRangePicker'
import pagination from '@crud/Pagination'
export default {
  name: 'BisLog',
  components: { crudOperation, rrOperation, DateRangePicker, pagination },
  cruds() {
    return CRUD({ title: '文章', url: 'api/bislog', crudMethod: { ...crudBislog }})
  },
  mixins: [presenter(), header(), crud()],
  data() {
    return {
      depts: [],
      inOutTypeOptions: [
        { key: '1', display_name: '支出' },
        { key: '0', display_name: '收入' }
      ],
      businessTypeOptions: [
        { key: '0', display_name: '购买会员' },
        { key: '1', display_name: '购买文章' },
        { key: '2', display_name: '购买咨询' }
      ],
      rules: {
        name: [
          { required: true, message: '请输入名称', trigger: 'blur' }
        ],
        deptSort: [
          { required: true, message: '请输入序号', trigger: 'blur', type: 'number' }
        ]
      }
    }
  },
  created() {
    this.crud.optShow = {
      add: false,
      edit: false,
      del: false,
      download: true
    }
  },
  mounted() {

  },
  methods: {
  }
}
</script>

<style scoped>

</style>
